﻿using System;
using System.IO;
using System.Reflection;

namespace DssProxyLoader
{
	//there has been some reported issues with dssproxy.exe and dssnewservice.exe
	public class ProxyLoader
	{
		public static int Main(string[] args)
		{
			Assembly dssProxy = Assembly.LoadFile(
				Path.Combine(
					Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
					"dssproxy.exe"));
			if (dssProxy != null)
			{
				Type proxy = dssProxy.GetType("Microsoft.Dss.Tools.DssProxy.DssProxy");
				if (proxy != null)
				{
					MethodInfo mainMethod = proxy.GetMethod("Main", BindingFlags.NonPublic | BindingFlags.Static);
					if (mainMethod != null)
						return (int) mainMethod.Invoke(null, new object[]{args});
				}
			}
			return 1;
		}
	}
}